<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios的POST请求</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" placeholder="部门编号" v-model="dept.deptno"><br>
        <input type="text" placeholder="部门名称" v-model="dept.dname"><br>
        <input type="text" placeholder="所在地址" v-model="dept.loc"><br>
        <button @click="addDept">添加部门</button>
    </div>
</body>
</html>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            dept:{
                deptno:'',
                dname:'',
                loc:''
            },
            url:'http://localhost:8080/depts'
        },
        methods: {
            addDept(){
                axios.post(this.url,this.dept).then(res=>{
                    console.log(res);
                })
            }
        },
    });
</script>